<?php
/**
 * View Archivio Post LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    21-apr-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript">
    //<![CDATA[

    $(document).ready(function()
    {
	var pagination = $('#locations').pagination({
	    'targetUrl' : '/admin/ajax/list/locations',
	    'orderField' : 'location_name',
	    'orderDir' : 'asc'
	},function(){
	    $("a.contacts").fancybox({
		    'type' : 'ajax',
		    'showCloseButton' : false
		});    
	    }
	);
        
        $( "#searchField" ).keyup( function() {
            if($(this).val().length >= 3)
            {
                var pagination = $('#locations').pagination({
                    'targetUrl' : '/admin/search/locations/'+ $(this).val(),
                    'orderField' : 'location_name',
                    'orderDir' : 'asc'
                },function(){
                $("a.contacts").fancybox({
                        'type' : 'ajax',
                        'showCloseButton' : false
                    });    
                });
            }
            else if($(this).val().length == 0)
            {
                var pagination = $('#locations').pagination({
                    'targetUrl' : '/admin/ajax/list/locations',
                    'orderField' : 'location_name',
                    'orderDir' : 'asc'
                },function(){
                    $("a.contacts").fancybox({
                            'type' : 'ajax',
                            'showCloseButton' : false
                        });    
                    });                
            }
        });
        
    });

    //]]>
</script>
<div class="info">
    <h2>Archivio location</h2>
    <div>Per inserire un nuovo locale...</div>
</div>

<form>
    <ul>
	<li class="addnew">
	    <a class="button" href="nuovo">
		<img src="/images/admin/16x16/add-new.png" />Nuova Location
	    </a>
	</li>
	
	<li id="fo2li107" class="likert col4">
	    <div>
		<table>
		    <caption id="title107">
			Tot: <strong><?php echo count( $this->locations ) ?></strong> location.
                    <div class="searchBox">
                        <label class="search">Cerca</label>
                        <input class="search" id="searchField" class="text" type="search" value="">
                    </div>                        
		    </caption>
		    <thead>
                        <tr>
                            <td class="pagination" colspan="5">
                                <a class="prev" href="javascript: void(0);">&nbsp;</a>
                                <span class="loader">Sto caricando...</span>
                                <a class="next" href="javascript: void(0);">&nbsp;</a>
                            </td>
                        </tr>
			<tr>
			    <th class="sortable default {ref: 'location_name'}">Nome</th>
			    <td class="sortable default {ref: 'location_city'}">Citt&agrave;</td>
			    <td class="sortable default {ref: 'province_long_name'}">Provincia</td>
			    <td>Contatti</td>
			    <td>&nbsp;</td>
			</tr>
		    </thead>
		    <tbody id="locations">
			<!-- Questo contenuto viene rimpiazzato dalla paginazione-->
		    </tbody>
		    <tfoot>
                        <tr>
                            <td class="pagination" colspan="5">
                                <a class="prev" href="javascript: void(0);">&nbsp;</a>
                                <span class="loader">Sto caricando...</span>
                                <a class="next" href="javascript: void(0);">&nbsp;</a>
                            </td>
                        </tr>
		    </tfoot>
		</table>
	    </div>
	</li>	
	
    </ul>
</form>
